<?php

//use Illuminate\Support\Facades\Schema;
use Jialeo\LaravelSchemaExtend\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateShopOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('shop_orders', function (Blueprint $table) {
            $table->comment = '订单表';
            $table->increments('id')->comment('订单ID');
			$table->integer('user_id')->comment('用户ID');
			$table->string('order_no',100)->unique()->default('')->comment('订单号');
			$table->tinyInteger('status')->default(1)->comment('订单状态：1=待付款（可取消订单），2=待发货（可退款），3=待收货（可退款/退货），4=待评价，5=取消订单，6=退款中，7=退款被拒绝，8=已退款，9=已完成');
			
			$table->decimal('total_money',8,2)->default('0.00')->comment('订单总金额：包括运费');
			
			$table->decimal('deliver_money',8,2)->default('0.00')->comment('运费	:运费规则按照每个规格计算');
			
			$table->tinyInteger('total_num')->comment('购买总数量');
			$table->tinyInteger('pay_from')->default(0)->comment('支付来源：1=钱包，2=微信');
			$table->string('user_name',30)->default('')->comment('收货人名称');
			$table->string('user_address',100)->default('')->comment('收件人地址');
			$table->string('user_phone',30)->default('')->comment('收件人手机');
			$table->integer('province_id')->comment('省ID');
			$table->integer('city_id')->comment('市ID');
			$table->integer('county_id')->comment('区ID');
			$table->timestamp('created_at')->nullable()->comment('创建时间');
			$table->timestamp('receive_time')->nullable()->comment('成交时间');
			$table->timestamp('delivery_time')->nullable()->comment('发货时间');
			$table->timestamp('pay_time')->nullable()->comment('付款时间');
			$table->text('content')->comment('订单详情：商品id,商品名称，商品规格id,商品规格，数量，价格');
			$table->string('prepay_id',100)->nullable()->comment('微信支付预订单id');
			$table->string('serial_number',100)->nullable()->comment('支付平台流水号');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('shop_orders');
    }
}
